<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // function show(msg) {

        //     //console.log(msg);
        //     return new Promise((resolve,reject)=> {
        //  if(msg === true){
             
        //      resolve("成功")
        //  }else{
        //      reject("失败")
        //  }
        //     })
        // }
        // // show(0);
        // // show(1)
        // show(true).then(val=>{
        //     console.log(val)
        // }).catch(err =>console.log(err))

        function show(time){
            return new Promise((resolve,reject)=>{
                setTimeout(()=>{
                    resolve(time *2)
                },500-time);
            })
        }
        
        function step(time){
            console.log(`正在处理中${time}`)
            return show(time);
        }

     async function work(){
            let time1=100;
            // step(time1)
            // .then(time2=>step(time2))
            // .then(time3=>step(time3))
            // .then(res => {
            //     console.log("工作完成!")
            // })
         let time2 = await step(time1);//第一步
         let time3 = await step(time2);//第二步
         let time4 = await step(time3);//第三步
         console.log("工作完成!")
        }

        work();
    </script>
</head>
<body>
    
</body>
</html>